<template>
	<view class="serviceorder">

		<u-overlay class="van-overlay" :show="showobj">
			<view class="wrapper" style="margin: 82% 11%;">
				<view class="top">
					<u-icon name="close-circle" color="#FFFFFF" size="24px" @click="sb" />
				</view>
				<view class="zhong">
					<image src="../../static/imgs/dingwei.png" class="img"></image>
				</view>
				<view class="bottom">已通知用户到达目的地</view>
				<view class="paizhao" @click="photograph">
					拍照上传
				</view>
			</view>

		</u-overlay>
		<u-overlay class="van-overlay" :show="showobjs">
			<view class="wrapper" style="margin: 82% 11%;">
				<view class="top">
					<u-icon name="close-circle" color="#FFFFFF" size="24px" @click="sbb" />
				</view>
				<view class="zhong">
					<image src="../../static/imgs/chufa.png" class="img"></image>
				</view>
				<view class="bottom">通知用户技师已出发</view>
				<view class="paizhao" @click="determine">
					确认
				</view>
			</view>
		</u-overlay>
		<view class="serviceorder_box">

			<view class="mallorders__dibu">
				<text @click="tabs(item.status)" v-for="item in list" :class="pageid==item.status ? 'active' : ''"
					:key="item.id">{{item.title}}</text>

			</view>
			<view class="serviceorder_box_top" v-if="pageid==-9">
				<view v-if="isshow" style="text-align: center;margin-top: 300rpx;">
					<image src="../../static/iconShow/noOrder.png"></image>
				</view>
				<view class="serviceorder_box_top_a" v-for="item in lists" :key="item.id">
					<view class="serviceorder_box_top_shang" v-if="item.status==1">
						<!-- <text class="text2" v-if="item.status==1">待接单</text> -->
						<!-- <text class="text2" v-if="item.status==2">已出发</text>
						<text class="text2" v-if="item.status==3">已到达</text> -->
						<text class="text1">预约时间：{{item.expectStartTime}} 时长：{{item.expectServiceTime}}分钟</text>
					</view>
					<view class="serviceorder_box_top_shang" v-if="item.status==6">
						<text class="text1">服务完成时间：{{item.realEndTime}}</text>

					</view>

					<u-count-down class="count-down" use-slot :time="time" @change="onChange" v-if="item.status==5">
						<text class="text_a">距离结束还剩</text>
						<text class="item"><text v-if="timeData.hours < 10">0</text>{{ timeData.hours }}</text>
						<text class="item_a">:</text>
						<text class="item"><text v-if="timeData.minutes < 10">0</text>{{ timeData.minutes }}</text>
						<text class="item_a">:</text>
						<text class="item"><text v-if="timeData.seconds < 10">0</text>{{ timeData.seconds }}</text>
					</u-count-down>
					<view class="content_main_zhong" v-for="it in item.cartInfos" :key="it.id">
						<view class="content_main_zhong_left">
							<image class="image" :src="it.image"></image>
						</view>
						<view class="content_main_zhong_right">
							<view class="content_main_zhong_right_s">
								<view class="content_main_zhong_right_tuina">
									<text class="text1">{{it.serviceName}}</text>
									<text class="text3" v-if="item.status==5">服务中</text>
									<text class="text2">X{{it.num}}</text>
								</view>
								<text class="text4" v-if="item.status==1">待接单</text>
								<view class="text2" v-if="item.status==2">已接单</view>
								<view class="text2" v-if="item.status==3">已出发</view>
								<view class="text2" v-if="item.status==4">已到达</view>
								<view class="text2" v-if="item.status==6">已完成</view>
							</view>
							<view class="content_main_zhong_right_shijian" v-if="item.status==1||item.status==6">
								订单号：{{it.orderId}}
							</view>
							<view class="content_main_zhong_right_shijian"
								v-if="item.status==3||item.status==4||item.status==2">
								预约时间：{{item.expectStartTime}}
							</view>
							<view class="content_main_zhong_right_shijian" v-if="item.status==5">
								<view style="display: flex;">
									<u-icon name="clock-fill" size="14" color="#0EA970" />
									<view class="content_main_zhong_right_shijian_kaishi" style="margin-left: 10rpx;">
										<text>开始时间：</text>
										<text>{{item.realStartTime}}</text>
									</view>
								</view>

								<view class="content_main_zhong_right_shichang">
									<u-icon name="clock-fill" size="14" color="#0EA970" />
									<text style="margin-left: 10rpx;"> 时长：</text>
									<text>{{item.expectServiceTime}}</text>
								</view>
							</view>
							<view class="content_main_zhong_right_bottom">
								<view class="content_main_zhong_right_left">
									<text class="text1">服务费</text>
									<text class="text2">￥
										<text>{{item.realMoney}}</text></text>
								</view>
								<view class="content_main_zhong_right_zhong">|</view>
								<view class="content_main_zhong_right_right">
									<text class="text1">交通费</text>
									<text class="text2">
										￥<text>
											{{item.travelCost}}</text></text>
								</view>
							</view>

						</view>


					</view>
					<view class="serviceorder_youhui_a" v-if="item.status==2||item.status==3||item.status==4">
						<view class="serviceorder_a">
							<text class="text1">订单编号：</text>
							<text class="text2">{{item.orderId}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">下单时间：</text>
							<text class="text2">{{item.createTime}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">预约时间：</text>
							<text class="text2">{{item.expectStartTime}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a"
						v-if="item.status==2||item.status==3||item.status==4||item.status==5||item.status==6">
						<view class="serviceorder_a">
							<text class="text1">服务时长：</text>
							<text class="text2">{{item.expectServiceTime}}分钟</text>
						</view>
					</view>
					<view class="serviceorder_youhui" v-if="item.status==2||item.status==3||item.status==4">
						<view class="serviceorder_a">
							<text class="text1">优惠卷：</text>
							<text class="text2">-￥{{item.feeRemission}}</text>
						</view>
					</view>
					<!-- <view class="serviceorder_youhui_a" v-if="item.status==5||item.status==6">
						<view class="serviceorder_a">
							<text class="text1">服务时长：</text>
							<text class="text2">{{item.liu}}</text>
						</view>
					</view> -->
					<view class="serviceorder_youhui" v-if="item.status==5">
						<view class="serviceorder_a">
							<text class="text1">优惠卷：</text>
							<text class="text2">-￥{{item.feeRemission}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">备注：</text>
							<text class="text2" style="display: block;width: 80%;">{{item.remark}}</text>
						</view>
					</view>
					<!-- <view class="serviceorder_youhui" >
						<view class="serviceorder_a">
							<text class="text1">备注：</text>
							<text class="text2">{{item.remark}}</text>
						</view>
					</view> -->
					<view class="serviceorder_daohang"
						v-if="item.status==1||item.status==2||item.status==3||item.status==4">
						<view class="serviceorder_daohang_left">服务地址：</view>
						<view class="serviceorder_daohang_right">

							<text class="text1"
								@click="copyAddress(item.customerAddress)">{{item.customerAddress}}</text>
							<image class="img" src="../../static/imgs/dh.png" mode="widthFix"
								@click="gotoMap(item.customerLatitude,item.customerLongitude,item.customerAddress)">
							</image>
						</view>
					</view>


					<view class="shifu">
						<!-- <view class="box1">
							<text class="text2">技师：</text>
							<text class="text3">￥132.00</text>
						</view> -->
						<view class="box2">
							<text class="text">实付：</text>
							<text class="text1">￥{{item.payMoney}}</text>
						</view>
						<!-- <text class="text">实付：</text>
						<text class="text1">{{item.shifu}}</text> -->
					</view>
					<view class="serviceorder_bottom">
						<text class="text1" v-if="item.status==1" @click="cancel(item)">取消订单</text>
						<view class="text3" v-if="item.status==1||item.status==2||item.status==3||item.status==4"
							@click="client(item.id)">
							<image class="img" src="../../static/imgs/dianhua.png"></image>
							联系客户
						</view>
						<text class="text2" v-if="item.status==1" @click="Immediately(item.orderId)">立即接单</text>
						<text class="text2" v-if="item.status==2" @click="chufa(item.orderId)">已出发</text>
						<text class="text2" v-if="item.status==3" @click="havearrived(item.orderId)">已到达</text>
						<text class="text2" v-if="item.status==4" @click="StartService(item.orderId)">开始服务</text>
					</view>
					<view class="fuwuzhong" v-if="item.status==5" @click="inservice(item.orderId)">
						服务中
					</view>
					<view style="width: 100%;height: 30rpx;" v-if="item.status==5">

					</view>

				</view>
			</view>
			<view class="serviceorder_box_top" v-if="pageid==1">
				<view v-if="isshow" style="text-align: center;margin-top: 300rpx;">
					<image src="../../static/iconShow/noOrder.png"></image>
				</view>
				<view class="serviceorder_box_top_a" v-for="item in lists1" :key="item.id">
					<view class="serviceorder_box_top_shang">
						<text class="text1">预约时间：{{item.expectStartTime}} 时长：{{item.expectServiceTime}}分钟</text>

					</view>
					<view class="content_main_zhong" v-for="it in item.cartInfos" :key="it.id">
						<view class="content_main_zhong_left">
							<image class="image" :src="it.image"></image>
						</view>
						<view class="content_main_zhong_right">
							<view class="content_main_zhong_right_s">
								<view class="content_main_zhong_right_tuina">
									<text class="text1">{{it.serviceName}}</text>
									<text class="text2">X{{it.num}}</text>
								</view>
								<view class="yijidan">待接单</view>

								<!-- <view class="text_d">
									<image src="../../static/img/dianhua1.png" class="img"></image>
								</view> -->
							</view>

							<view class="content_main_zhong_right_shijian">
								订单号：{{it.orderId}}
							</view>
							<view class="content_main_zhong_right_bottom">
								<view class="content_main_zhong_right_left">
									<text class="text1">服务费</text>
									<text class="text2">￥
										<text>{{item.realMoney}}</text></text>
								</view>
								<view class="content_main_zhong_right_zhong">|</view>
								<view class="content_main_zhong_right_right">
									<text class="text1">交通费</text>
									<text class="text2">￥<text>
											{{item.travelCost}}</text></text>
								</view>
							</view>

						</view>


					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">下单时间：</text>
							<text class="text2">{{item.createTime}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">预约时间：</text>
							<text class="text2">{{item.expectStartTime}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a" v-if="item.num==2">
						<view class="serviceorder_a">
							<text class="text1">服务时长：</text>
							<text class="text2">{{item.liu}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui">
						<view class="serviceorder_a">
							<text class="text1">优惠卷：</text>
							<text class="text2">{{item.feeRemission}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">备注：</text>
							<text class="text2" style="display: block;width: 80%;">{{item.remark}}</text>
						</view>
					</view>
					<view class="serviceorder_daohang">
						<view class="serviceorder_daohang_left">服务地址：</view>
						<view class="serviceorder_daohang_right">

							<text class="text1"
								@click="copyAddress(item.customerAddress)">{{item.customerAddress}}</text>
							<image class="img" src="../../static/imgs/dh.png" mode="widthFix"
								@click="gotoMap(item.customerLatitude,item.customerLongitude,item.customerAddress)">
							</image>
						</view>
					</view>
					<view class="shifu">
						<!-- <view class="box1">
							<text class="text2">技师：</text>
							<text class="text3">￥132.00</text>
						</view> -->
						<view class="box2">
							<text class="text">实付：</text>
							<text class="text1">￥{{item.payMoney}}</text>
						</view>

					</view>
					<view class="serviceorder_bottom">
						<text class="text1" @click="cancel(item)">取消订单</text>
						<view class="text3" @click="clients(item.id)">
							<image class="img" src="../../static/imgs/dianhua.png"></image>
							联系客户
						</view>
						<text class="text2" @click="Immediately(item.orderId)">立即接单</text>
					</view>

				</view>
			</view>
			<view class="serviceorder_box_top" v-if="pageid==2">
				<view v-if="isshow" style="text-align: center; margin-top: 300rpx;">
					<image src="../../static/iconShow/noOrder.png"></image>
				</view>
				<view class="serviceorder_box_top_a" v-for="(item,index) in lists2" :key="index">


					<u-count-down class="count-down" use-slot :time="time" @change="onChange" v-if="item.status==5">
						<text class="text_a">距离结束还剩</text>
						<text class="item"><text v-if="timeData.hours < 10">0</text>{{ timeData.hours }}</text>
						<text class="item_a">:</text>
						<text class="item"><text v-if="timeData.minutes < 10">0</text>{{ timeData.minutes }}</text>
						<text class="item_a">:</text>
						<text class="item"><text v-if="timeData.seconds < 10">0</text>{{ timeData.seconds }}</text>
					</u-count-down>
					<view class="content_main_zhong" v-for="it in item.cartInfos" :key="it.id">
						<view class="content_main_zhong_left">
							<image class="image" :src="it.image"></image>
						</view>
						<view class="content_main_zhong_right">
							<view class="content_main_zhong_right_s">
								<view class="content_main_zhong_right_tuina">
									<text class="text1">{{it.serviceName}}</text>
									<text class="text3" v-if="item.status==5">服务中</text>
									<text class="text2">X{{it.num}}</text>
								</view>
								<view class="text2" v-if="item.status==2">已接单</view>
								<view class="text2" v-if="item.status==3">已出发</view>
								<view class="text2" v-if="item.status==4">已到达</view>
								<view class="text2" v-if="item.status==6">已完成</view>
								<!-- <view class="yijidan" v-if="item.num==2">{{item.yjd}}</view>
								
								<view class="text_d" v-if="item.num==1">
									<image :src="item.src1" class="img"></image>
								</view> -->
							</view>
							<!-- <view class="content_main_zhong_right_shijian" v-if="item.num==1||item.num==3">
								{{item.ddh}}
							</view> -->
							<view class="content_main_zhong_right_shijian"
								v-if="item.status==2||item.status==3||item.status==4">
								预约时间：{{item.expectStartTime}}
							</view>
							<view class="content_main_zhong_right_shijian" v-if="item.status==5">

								<view style="display: flex;">
									<u-icon name="clock-fill" size="14" color="#0EA970" />
									<view class="content_main_zhong_right_shijian_kaishi" style="margin-left: 10rpx;">
										<text>开始时间：</text>
										<text>{{item.realStartTime}}</text>
									</view>
								</view>

								<view class="content_main_zhong_right_shichang">
									<u-icon name="clock-fill" size="14" color="#0EA970" />
									<text style="margin-left: 10rpx;"> 时长：</text>
									<text>{{item.expectServiceTime}}分钟</text>
								</view>
							</view>
							<view class="content_main_zhong_right_bottom">
								<view class="content_main_zhong_right_left">
									<text class="text1">服务费</text>
									<text class="text2">￥
										<text>{{item.realMoney}}</text></text>
								</view>
								<view class="content_main_zhong_right_zhong">|</view>
								<view class="content_main_zhong_right_right">
									<text class="text1">交通费</text>
									<text class="text2">￥<text>
											{{item.travelCost}}</text></text>
								</view>
							</view>

						</view>


					</view>
					<!-- <view class="serviceorder_youhui_a" v-if="item.num==3">
						<view class="serviceorder_a">
							 <text class="text1">预约时间：</text>
							 <text class="text2">{{item.sss}}</text>
						</view>
					</view> -->
					<view class="serviceorder_youhui_a" v-if="item.status==2||item.status==3||item.status==4">
						<view class="serviceorder_a">
							<text class="text1">订单编号：</text>
							<text class="text2">{{item.orderId}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">下单时间：</text>
							<text class="text2">{{item.createTime}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">预约时间：</text>
							<text class="text2">{{item.expectStartTime}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a" v-if="item.status==2||item.status==3||item.status==4">
						<view class="serviceorder_a">
							<text class="text1">服务时长：</text>
							<text class="text2">{{item.realServiceTime}}分钟</text>
						</view>
					</view>
					<view class="serviceorder_youhui" v-if="item.status==2||item.status==3||item.status==4">
						<view class="serviceorder_a">
							<text class="text1">优惠卷：</text>
							<text class="text2">{{item.feeRemission}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a" v-if="item.status==5">
						<view class="serviceorder_a">
							<text class="text1">服务时长：</text>
							<text class="text2">{{item.realServiceTime}}分钟</text>
						</view>
					</view>
					<view class="serviceorder_youhui" v-if="item.status==5">
						<view class="serviceorder_a">
							<text class="text1">优惠卷：</text>
							<text class="text2">{{item.feeRemission}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">备注：</text>
							<text class="text2" style="display: block;width: 80%;">{{item.remark}}</text>
						</view>
					</view>
					<view class="serviceorder_daohang" v-if="item.status==2||item.status==3||item.status==4">
						<view class="serviceorder_daohang_left">服务地址：</view>
						<view class="serviceorder_daohang_right">

							<text class="text1"
								@click="copyAddress(item.customerAddress)">{{item.customerAddress}}</text>
							<image class="img" src="../../static/imgs/dh.png" mode="widthFix"
								@click="gotoMap(item.customerLatitude,item.customerLongitude,item.customerAddress)">
							</image>
						</view>
					</view>
					<view class="shifu">
						<!-- <view class="box1">
							<text class="text2">技师：</text>
							<text class="text3">￥132.00</text>
						</view> -->
						<view class="box2">
							<text class="text">实付：</text>
							<text class="text1">￥{{item.payMoney}}</text>
						</view>

					</view>

					<view class="lianxi">
						<!-- <text class="text3" v-if="item.status==2||item.status==3||item.status==4"
							@click="cancel(item)">取消订单</text> -->
						<view class="text1" v-if="item.status==2||item.status==3||item.status==4"
							@click="clientss(item.id)">
							<image class="img" src="../../static/imgs/dianhua.png"></image>
							联系客户
						</view>
						<text class="text2" v-if="item.status==2" @click="chufa(item.orderId)">已出发</text>
						<text class="text2" v-if="item.status==3" @click="havearrived(item.orderId)">已到达</text>
						<text class="text2" v-if="item.status==4" @click="StartService(item.orderId)">开始服务</text>
					</view>
					<view class="fuwuzhong" v-if="item.status==5" @click="inservice(item.orderId)">
						服务中
					</view>
					<view style="width: 100%;height: 30rpx;" v-if="item.status==5">

					</view>
				</view>
			</view>
			<view class="serviceorder_box_top" v-if="pageid==3">
				<view v-if="isshow" style="text-align: center;margin-top: 300rpx;">
					<image src="../../static/iconShow/noOrder.png"></image>
				</view>
				<view class="serviceorder_box_top_a" v-for="item in lists3" :key="item.id">
					<view class="serviceorder_box_top_shang">
						<text class="text1">服务完成时间：{{item.realEndTime}}</text>

					</view>
					<view class="content_main_zhong" v-for="it in item.cartInfos" :key="it.id">
						<view class="content_main_zhong_left">
							<image class="image" :src="it.image"></image>
						</view>
						<view class="content_main_zhong_right">
							<view class="content_main_zhong_right_s">
								<view class="content_main_zhong_right_tuina">
									<text class="text1">{{it.serviceName}}</text>
									<text class="text2">X{{it.num}}</text>
								</view>
								<view class="yijidan" v-if="item.status==6">已完成</view>

								<!-- <view class="text_d" v-if="item.num==1">
									<image :src="item.src1" class="img"></image>
								</view> -->
							</view>
							<view class="content_main_zhong_right_shijian">
								订单号：{{it.orderId}}
							</view>
							<!-- <view class="content_main_zhong_right_shijian" v-if="item.num==2">
								{{item.yysj}}
							</view> -->
							<view class="content_main_zhong_right_bottom">
								<view class="content_main_zhong_right_left">
									<text class="text1">服务费</text>
									<text class="text2">￥
										<text>{{item.totalMoney}}</text></text>
								</view>
								<view class="content_main_zhong_right_zhong">|</view>
								<view class="content_main_zhong_right_right">
									<text class="text1">交通费</text>
									<text class="text2">￥<text>
											{{item.travelCost}}</text></text>
								</view>
							</view>

						</view>


					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">下单时间：</text>
							<text class="text2">{{item.createTime}}</text>
						</view>
					</view>

					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">预约时间：</text>
							<text class="text2">{{item.expectStartTime}}</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">服务时长：</text>
							<text class="text2">{{item.expectServiceTime}}分钟</text>
						</view>
					</view>
					<view class="serviceorder_youhui_a">
						<view class="serviceorder_a">
							<text class="text1">备注：</text>
							<text class="text2" style="display: block;width: 80%;">{{item.remark}}</text>
						</view>
					</view>

					<view class="shifu">

						<view class="box2">
							<text class="text">实付：</text>
							<text class="text1">￥{{item.payMoney}}</text>
						</view>

					</view>
					<view class="serviceorder_bottom" v-if="item.num==1">
						<text class="text1">取消订单</text>
						<text class="text2">立即接单</text>
					</view>
					<view class="lianxi" v-if="item.num==2">

						<view class="text1" @click="client">
							<image class="img" src="../../static/imgs/dianhua.png"></image>
							联系客户
						</view>
						<text class="text2">已到达</text>
					</view>
				</view>
			</view>

		</view>
		<u-overlay class="van-overlay_a" :show="showobjsss">
			<view class="wrapper" style="height: 100%;width: 100%;">
				<image :src="tupian" style="height: 100%;width: 100%;"></image>
				<view class="bottom" @click="Confirmtoupload">确认上传</view>
			</view>
		</u-overlay>


		<u-popup class="u-popup" :show="showtc" mode="center" @close="close" @open="open">
			<view class="cancellationoforder_box">
				<view class="cancellationoforder_box_top">
					<view class="cancellationoforder_box_top_shang">请输入结束订单原因</view>


					<view class="wenben">
						<textarea v-model="reason" class="ipt"></textarea>
					</view>
				</view>
				<view class="cancellationoforder_box_bottom" @click="theservice">
					提交
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import homeServices from '../../service/homeService'
	export default {
		data() {
			return {
				showtc: false,
				ID: -9,
				obj: false,
				showobj: false,
				showobjs: false,
				showobjsss: false,
				showobjssss: false,
				boss: true,
				boo: false,
				boos: false,
				b: true,
				queding: '',
				list: [

					{
						id: 1,
						title: '全部订单',
						status: -9,
					},
					{
						id: 2,
						title: '待接单',
						status: 1
					},
					{
						id: 3,
						title: '进行中',
						status: 2
					},
					{
						id: 4,
						title: '已完成',
						status: 3
					},

				],
				lists: [],
				lists1: [],
				lists2: [],
				lists3: [],
				serviceorderlist: [],
				status: '',
				ids: '',
				orderId: '',
				uploadFile: '',
				tupian: '',
				countDownTime: '',
				arr: '',
				time: 1,
				timeData: {},
				idssss: '',
				gettime: "",
				cancelid: '',
				cancelorderId: '',
				chufaid: '',
				customerPhone: '',
				isshow: false,
				reason: '',
				pageid: '-9',

				// time: 0

			}
		},
		methods: {
			gotoMap(a, b, c) {
				this.navigaToMap(a, b, c)
			},
			navigaToMap(latitude, longitude, name) {
				let hasBaiduMap = plus.runtime.isApplicationExist({
					pname: 'com.baidu.BaiduMap',
					action: 'baidumap://'
				});
				let hasAmap = plus.runtime.isApplicationExist({
					pname: 'com.autonavi.minimap',
					action: 'androidamap://'
				});
				let urlBaiduMap =
					`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&coord_type=gcj02&src=andr.baidu.openAPIdemo`
				urlBaiduMap = encodeURI(urlBaiduMap)
				let urlAmap =
					`androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`
				// urlAmap = urlAmap(urlBaiduMap)
				if (hasAmap && hasBaiduMap) {
					plus.nativeUI.actionSheet({
						title: "选择地图应用",
						cancel: "取消",
						buttons: [{
							title: "百度地图"
						}, {
							title: "高德地图"
						}]
					}, function(e) {
						switch (e.index) {
							case 1:
								plus.runtime.openURL(urlBaiduMap);
								break;
							case 2:
								plus.runtime.openURL(urlAmap);
								break;
						}
					})
				} else if (hasAmap) {
					plus.runtime.openURL(urlAmap);
				} else if (hasBaiduMap) {
					plus.runtime.openURL(urlBaiduMap);
				} else {
					plus.nativeUI.alert("本机未安装指定的地图应用");
					// url = "geo:"+latitude+","+longitude+"?q=%e6%95%b0%e5%ad%97%e5%a4%a9%e5%a0%82";
					// plus.runtime.openURL(url); //如果是国外应用，应该优先使用这个，会启动google地图。这个接口不能统一坐标系，进入百度地图时会有偏差  
				}
			},
			copyAddress(val) {
				uni.setClipboardData({
					data: val,
					success: () => {
						uni.showToast({
							title: "复制成功"
						})
					}
				});
			},
			async getserviceorder() {

				let params = {
					type: this.pageid
				}

				let res = await homeServices.getserviceorder(params)
				console.log(res.data, 666666666666)
				this.lists = res.data
				this.lists.forEach(it => {
					if (it.status == 5) {
						this.countDownTime = it.countDownTime
						this.getlis()
					}
				})
				if (this.lists.length == 0) {
					this.isshow = true
				} else {
					this.isshow = false
				}

				// if (uni.getStorageSync('countDownTime')) {
				// 	this.getlis()
				// }
				// this.tabs(2)
			},
			// tab
			async tabs(ida) {
				// console.log(ida, 'hhhhhhhhhhhh')
				// this.status = ida
				this.pageid = ida
				console.log(this.pageid);

				let params = {
					type: this.pageid
				}

				let res = await homeServices.tabs(params)
				// console.log(res)
				// console.log(res.data[0]);
				if (ida == 1) {
					this.lists1 = res.data
					this.pageid = 1
					// console.log(res)
					if (this.lists1.length == 0) {
						this.isshow = true

					} else {
						this.isshow = false
					}

					// this.customerPhone = res.data[0].customerPhone
					if (this.lists1.length == 0) {
						return
					} else {
						// this.customerPhone = res.data[0].customerPhone
					}
					// this.tabs(1)



				} else if (ida == 2) {

					this.lists2 = res.data
					console.log(this.lists2);
					if (this.lists2.length == 0) {
						this.isshow = true
					} else {
						this.isshow = false
					}
					if (this.lists2.length == 0) {
						return
					} else {
						// this.customerPhone = res.data[0].customerPhone
						// this.countDownTime = res.data[0].countDownTime
						// console.log(this.customerPhone,this.countDownTime)
					}


					// uni.setStorageSync('countDownTime', this.countDownTime)
				} else if (ida == 3) {
					this.lists3 = res.data
					if (this.lists3.length == 0) {
						this.isshow = true
					} else {
						this.isshow = false
					}
					if (this.lists3.length == 0) {
						return
					} else {
						// this.customerPhone = res.data[0].customerPhone
					}


				} else {
					this.lists = res.data
					this.lists.forEach(it => {
						if (it.status == 5) {
							this.countDownTime = it.countDownTime

						}
					})
					if (this.lists.length == 0) {
						this.isshow = true
					} else {
						this.isshow = false
					}
					if (this.lists.length == 0) {
						return
					} else {
						// this.customerPhone = res.data[0].customerPhone
					}

					this.getlis()

				}


				// if (uni.getStorageSync('countDownTime')) {
				// 	this.getlis()
				// }


			},
			async Immediately(item) {

				this.orderId = item
				let params = {
					type: 2,
					orderId: this.orderId
				}

				let res = await homeServices.Immediately(params)
				console.log(res);
				if (res.status == 200) {
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
					this.tabs(2)
				} else {
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
				}


			},
			ordeform() {

			},
			havearrived(orderId) {
				this.queding = orderId
				this.showobj = true


			},
			// 电话
			client(id) {
				this.lists.forEach(it => {
					if (it.id == id) {
						this.customerPhone = it.customerPhone
						console.log(this.customerPhone, 'vvvvvvvvv')
					}
				})
				uni.makePhoneCall({
					phoneNumber: this.customerPhone //仅为示例   
				});
			},
			clients(id) {
				this.lists1.forEach(it => {
					if (it.id == id) {
						this.customerPhone = it.customerPhone
						console.log(this.customerPhone, 'vvvvvvvvv')
					}
				})
				uni.makePhoneCall({
					phoneNumber: this.customerPhone //仅为示例   
				});
			},
			clientss(id) {
				this.lists2.forEach(it => {
					if (it.id == id) {
						this.customerPhone = it.customerPhone
						console.log(this.customerPhone, 'vvvvvvvvv')
					}
				})
				uni.makePhoneCall({
					phoneNumber: this.customerPhone //仅为示例   
				});
			},
			// 已出发
			chufa(orderId) {
				this.chufaid = orderId
				this.showobjs = true

			},
			sb() {
				this.showobj = false

			},
			sbb() {
				this.showobjs = false

			},
			// 出发确定
			async determine() {
				let params = {
					type: 3,
					orderId: this.chufaid
				}

				let res = await homeServices.Immediately(params)
				// this.getserviceorder()
				this.tabs(2)
				this.showobjs = false
			},
			shang() {
				console.log(123)
				uni.switchTab({
					url: '/pages/my/my'
				})
			},

			vanicon() {
				this.showobjssss = false
			},
			// 取消订单
			cancel(item) {

				let cancelid = item.id
				let cancelorderId = item.orderId
				let status = item.status
				console.log(cancelid, cancelorderId, '000000000000000')
				uni.navigateTo({
					url: `../ordeform/ordeform?id=${cancelid}&cancelorderId=${cancelorderId}&status=${status}`
				})
			},
			photograph() {
				// let that = this
				// let uploadFile = ''
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'],
					sourceType: ['camera'], //这要注意，camera掉拍照，album是打开手机相册
					success: res => {
						console.log(res);
						this.uploadFile = res.tempFilePaths[0];
						console.log(this.uploadFile)
						this.showobjsss = true
						this.showobj = false

						uni.uploadFile({
							// 需要上传的地址
							url: 'http://anerle.ysguanjia.com/consumerapi/imgUpload',
							// filePath  需要上传的文件
							filePath: res.tempFilePaths[0],
							name: 'file',


							success: res => {
								// console.log(res)
								let res1 = JSON.parse(res.data);
								let data1 = res1.data[0];
								this.tupian = data1
								console.log(this.tupian, 'ppppppppp')
							}

						});
						// uni.navigateTo({
						// 	url: `/pagesA/photograph/photograph?tempFilePaths=${tempFilePaths}`
						// })

					}
				});

			},
			// 开始服务
			async StartService(orderId) {
				let ids = orderId
				let params = {
					type: 5,
					orderId: ids
				}

				let res = await homeServices.Immediately(params)
				console.log(res, 'llllllllllllllll')
				this.getserviceorder()
				this.tabs(2)

				console.log(this.time)
			},

			// 确认上传
			async Confirmtoupload() {
				let params = {
					type: 4,
					orderId: this.queding,
					sceneImage: this.tupian
				}

				let res = await homeServices.Immediately(params)
				this.showobjsss = false
				this.tabs(2)
			},
			// 服务中
			inservice(orderId) {
				this.idssss = orderId
				console.log(this.idssss)
				this.showtc = true

			},
			close() {
				this.reason = ''
				this.showtc = false
			},
			open() {

			},
			// 结束服务
			async theservice() {
				if (this.reason.trim() == '') {
					uni.showToast({
						title: '请输入取消原因',
						icon: 'none'
					})
					return
				} else {
					let params = {
						type: 6,
						orderId: this.idssss,
						earlyEndReason: this.reason
					}

					let res = await homeServices.Immediately(params)
					console.log(res)
					this.reason = ''
					this.tabs(2)
					// this.tabs(3)
					// this.getserviceorder()
					this.showtc = false
				}

			},
			onChange(e) {
				// console.log(e,999999)
				this.timeData = e
				if (e.hours == 0 && e.minutes == 5) {
					uni.showToast({
						title: '成功提示',
						//将值设置为 success 或者直接不用写icon这个参数
						icon: 'success',
						//显示持续时间为 2秒
						duration: 2000
					})
				}
			},
			getlis() {
				let yy = new Date().getFullYear();
				var mm =
					new Date().getMonth() < 10 ?
					"0" + (new Date().getMonth() + 1) :
					new Date().getMonth() + 1;
				var dd =
					new Date().getDate() < 10 ?
					"0" + new Date().getDate() :
					new Date().getDate();
				let hh = new Date().getHours();
				let mf =
					new Date().getMinutes() < 10 ?
					"0" + new Date().getMinutes() :
					new Date().getMinutes();
				let ss =
					new Date().getSeconds() < 10 ?
					"0" + new Date().getSeconds() :
					new Date().getSeconds();
				this.gettime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
				// console.log(this.gettime)
				console.log(this.countDownTime);
				console.log(new Date(this.countDownTime).getTime());
				console.log(new Date(this.gettime).getTime());
				let arr = new Date(this.countDownTime).getTime() - new Date(this.gettime).getTime();
				console.log(arr)
				this.time = arr
			}
		},
		onLoad() {
			console.log(this.pageid);
			this.getserviceorder()



		},
		onShow() {
			// this.lists1=[]

			this.tabs(this.pageid)
			// this.getserviceorder()
			// this.tabs(-9)

		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/sass/serviceorder.scss'
</style>
